<!DOCTYPE html>
<html>
<head>
	<!-- Google Tag Manager -->
	<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
	new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
	j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
	'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
	})(window,document,'script','dataLayer','GTM-W8KNPT4');</script>
	<!-- End Google Tag Manager -->
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width,inital-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
	<meta name="format-detection" content="telephone=no">
    <title>博猫体育</title>
    <link rel="stylesheet" href="css/app.min.css?ver=1.0.000">
    <link rel="stylesheet" href="css/iconfont.css?ver=1.0.000">
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
    <script src="js/pageLib.js"></script>
    <script src="js/clipboard.min.js"></script>
</head>
<body>
<div class="header">
	<div class="nav">
		<div class="title">充值</div>
		<a href="javascript:history.back(-1);" class="left-btn"><i class="iconfont icon-xitongfanhui icon-middle"></i></a>
		<!-- <div class="right-btn">登录 / 注册</div> -->
		<div class="right-btn">
			<!-- <div class="login flexer">
				<div class="balance">
					<div>余额</div>
					<div>￥888.88</div>
				</div>
				<div class="deposit"><a href="javascript:;">充值</a></div>
			</div> -->
		</div>
	</div>
</div>
<div class="table-content" style="padding-top:45px;padding-bottom:120px;">
	<form class="deposit-form" id="deposit-form">
		<!-- <ul class="form-list">
			<li class="form-row">
				<div class="account-status content">加载中...</div>
			</li>
		</ul> -->
		<ul class="form-list">
			<li class="form-row">
				<div class="content">选择充值金额</div>
				<div class="button-row amount-select">
					<a class="amount-btn" data-value="50" href="javascript:;">￥50</a>
					<a class="amount-btn active" data-value="100" href="javascript:;">￥100</a>
					<a class="amount-btn" data-value="200" href="javascript:;">￥200</a>
					<a class="amount-btn" data-value="500" href="javascript:;">￥500</a>
					<!-- <a class="amount-btn" data-value="500" href="javascript:;">￥500</a> -->
					<a class="amount-btn" data-value="1000" href="javascript:;">￥1000</a>
					<input class="amount-btn customized" placeholder="自定义金额">
				</div>
			</li>
		</ul>
		<ul class="form-list payment-method-select">
			<li class="form-row">
				<div class="content" id="deposit-promotion">
				充值送活动进行中，马上完成支付可获得：<br>
				即时到账<b style="color:#df3031;">￥110</b>，次月到账<b style="color:#df3031;">￥10</b>，第三个月到账<b style="color:#df3031;">￥10</b>
				</div>
			</li>
		</ul>
		<ul class="form-list payment-method-select">
			<li class="form-row">
				<div class="content">选择支付方式</div>
			</li>
			<li class="payment-method-cell form-row -with-icon active" data-method="alipay">
				<a href="javascript:;">
					<div class="icon"><img src="images/wechatpay.png"></div>
					<div class="label">银行卡快捷支付</div>
					<div class="badge"></div>
				</a>
			</li>
			<li class="payment-method-cell form-row -with-icon" data-method="ethereum">
				<a href="javascript:;">
					<div class="icon"><img src="images/ethereum.png"></div>
					<div class="label">以太坊ETH</div>
					<div class="badge"></div>
				</a>
			</li>
			<li class="payment-method-cell form-row -with-icon" data-method="otc">
				<a href="javascript:;">
					<div class="icon"><img src="images/alipay.png"></div>
					<div class="label">支付宝、微信转账</div>
					<div class="badge"></div>
				</a>
			</li>
		</ul>
		<ul class="form-list">
			<li class="form-row">
				<div class="content">温馨提示：</div>
			</li>
			<li class="form-row">
				<div class="content" style="font-size:13px;color:#666;">1、充值金额大于2000元，请联系平台的微信客服：keantim3 <a href="javascript:;" class="copy-btn" data-clipboard-text="keantim3">复制</a><br>2、如充值遇到异常或充值失败请及时联系平台客服，我们将进行人工处理</div>
			</li>
		</ul>
		<a href="javascript:;" class="submit">充值</a>
	</form>
</div>

</body>
<script type="text/javascript">
$(document).ready(function(){
	pageLib.initAffiliate();
	// 实例化复制按钮
	var clipboard=new ClipboardJS('.copy-btn');
	clipboard.on('success', function(e) {
		var target=$(e.trigger);
		target.text('已复制');
		setTimeout(function(){target.text('复制');},1000);
		e.clearSelection();
	});
	$('.amount-select .amount-btn').on('click',function(){
		if(!$(this).hasClass('active')){
			$(this).addClass('active').siblings().removeClass('active');
		}
		var amount=$('.amount-select .amount-btn.active').hasClass('customized') ? $('.amount-select .amount-btn.active').val() : $('.amount-select .amount-btn.active').data('value');
		amount=parseFloat(amount);
		var promAmount=null;
		if(amount>=1000){
			var promAmount=[amount+50,25,25];
		}
		else if(amount>=100){
			var promAmount=[amount+10,10,10];
		}
		else if(amount>=10){
			var promAmount=[amount+3,3,4];
		}
		if(promAmount){
			$('#deposit-promotion b').eq(0).text('￥'+promAmount[0]);
			$('#deposit-promotion b').eq(1).text('￥'+promAmount[1]);
			$('#deposit-promotion b').eq(2).text('￥'+promAmount[2]);
		}
		return;
	});
	$('.amount-select .amount-btn.customized').on('keyup',function(){
		if(!$(this).hasClass('active')){
			$(this).addClass('active').siblings().removeClass('active');
		}
		var amount=$('.amount-select .amount-btn.active').hasClass('customized') ? $('.amount-select .amount-btn.active').val() : $('.amount-select .amount-btn.active').data('value');
		amount=parseFloat(amount);
		var promAmount=null;
		if(amount>=1000){
			var promAmount=[amount+50,25,25];
		}
		else if(amount>=100){
			var promAmount=[amount+10,10,10];
		}
		else if(amount>=10){
			var promAmount=[amount+3,3,4];
		}
		if(promAmount){
			$('#deposit-promotion b').eq(0).text('￥'+promAmount[0]);
			$('#deposit-promotion b').eq(1).text('￥'+promAmount[1]);
			$('#deposit-promotion b').eq(2).text('￥'+promAmount[2]);
		}
		return;
	});
	$('.payment-method-select .payment-method-cell').on('click',function(){
		if(!$(this).hasClass('active')){
			$(this).addClass('active').siblings().removeClass('active');
		}
	});
	
	pageLib.api({
		action: '/v1/user/get-user-info?t='+(new Date()).valueOf(),
		success: function(resp){
			var mobile=resp.data.mobile;
			pageLib.setCookie('balance',(parseFloat(resp.data.balance)+parseFloat(resp.data.frozen_cash)+parseFloat(resp.data.red_cash)),0);
			$('.submit').on('click',function(){
				var amount=$('.amount-select .amount-btn.active').hasClass('customized') ? $('.amount-select .amount-btn.active').val() : $('.amount-select .amount-btn.active').data('value');
				amount=parseFloat(amount);
				if(amount<10){
					pageLib.alert('请至少充值10元');return;
				}
				var method=$('.payment-method-select .payment-method-cell.active').data('method');
				console.log(amount);
				console.log(method);
				switch(method){
					case 'alipay':
						$.ajax({
							url: '/api/index.php/Api/getXunjieDepositParametres?t='+(new Date()).valueOf(),
							type: 'post',
							dataType: 'json',
							data: {
								mobile: mobile,
								total_fee: amount
							},
							success: function(resp){
								console.log(resp);
								if(!resp.data){
									pageLib.alert('支付参数错误，请联系客服');
									return;
								}
								var form = $('<form name="pay" action="http://xiaogeng100.cn/Pay_Index.html" method="post"></form>')
								for(var key in resp.data){
								    form.append('<input type="hidden" name="'+key+'" value="'+resp.data[key]+'">');
								}
							    $(document.body).append(form);
							    form.submit();
							},
							error: function(){
								pageLib.alert('支付参数错误，请联系客服');
							}
						});
						break;
					case 'otc':
						$.ajax({
							url: '/api/index.php/Api/getStarFireDepositParametres?t='+(new Date()).valueOf(),
							type: 'post',
							dataType: 'json',
							data: {
								mobile: mobile,
								total_fee: amount
							},
							success: function(resp){
								console.log(resp);
								if(!resp.data){
									pageLib.alert('支付参数错误，请联系客服');
									return;
								}
								var form = $('<form name="pay" action="https://s.starfireotc.com/payLink/mobile.html" method="get"></form>')
								for(var key in resp.data){
								    form.append('<input type="hidden" name="'+key+'" value="'+resp.data[key]+'">');
								}
							    $(document.body).append(form);
							    form.submit();
							},
							error: function(){
								pageLib.alert('支付参数错误，请联系客服');
							}
						});
						break;
					case 'wechat':
						pageLib.alert('暂不支持微信支付充值');
						break;
					case 'ethereum':
						window.location.href="deposit-ethereum.html?amount="+amount;
						break;
					default:
						pageLib.alert('请选择支付方式');
				}
			});
		},
		error: function(XMLHttpRequest,err,exeption){
			if(XMLHttpRequest.status==401){
				$('#deposit-form .submit').text('登录/注册').attr('href','login.html');
			}
		}
	});
	// pageLib.api({
	// 	action: '/v1/user/get-user-info',
	// 	success: function(resp){
	// 		var availableBalance='￥'+(parseFloat(resp.data.balance)+parseFloat(resp.data.red_cash)).toFixed(2);
	// 		pageLib.setCookie('balance',(parseFloat(resp.data.balance)+parseFloat(resp.data.red_cash)),0);
	// 		$('.account-status').html('账号：'+resp.data.mobile.substr(0,4)+'****'+resp.data.mobile.substr(-4)+'<br>余额：'+availableBalance);
			
	// 	},
	// 	error: function(XMLHttpRequest,err,exeption){
	// 		if(XMLHttpRequest.status==401){
	// 			window.location.href="login.html";
	// 		}
	// 	}
	// });
});
</script>
</html>